﻿using Caliburn.Micro;
using myapp.Events;
using myapp.Events.ViewModel;
using myapp.Instances;
using myappcore.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace myapp.ViewModels
{
    /// <summary>
    /// Function Manager ViewModel
    /// </summary>
    public class FunctionManagerViewModel : IBaseContentViewModel, IHandle<ViewModelFunctionListShowEvent>
    {
        #region Attribute

        private IBaseContentViewModel _functionGroupListViewModel;
        private IBaseContentViewModel _functionListViewModel;
        private bool _isShowFunctionListViewModel;
        #endregion

        #region Properties

        /// <summary>
        /// List Group of Function
        /// </summary>
        public IBaseContentViewModel FunctionGroupListViewModel
        {
            get
            {
                return _functionGroupListViewModel;
            }
        }

        /// <summary>
        /// List Funtion of group selected
        /// </summary>
        public IBaseContentViewModel FunctionListViewModel
        {
            get
            {
                if (_isShowFunctionListViewModel)
                {
                    return _functionListViewModel;
                }
                return null;
            }
        }

        #endregion

        #region Constructor

        public FunctionManagerViewModel()
        {
            _functionGroupListViewModel = new FunctionGroupListViewModel();
            _functionListViewModel = new FunctionListViewModel();
            MainInstance.Instance.EventAggregator.Subscribe(this);
        }

        #endregion

        #region Method

        public void Handle(ViewModelFunctionListShowEvent message)
        {
            if (null != message && message.IsShow != _isShowFunctionListViewModel)
            {
                _isShowFunctionListViewModel = message.IsShow;
                NotifyOfPropertyChange(() => FunctionListViewModel);
            }
        }
        #endregion



    }
}
